package mysql


type Column struct {
	Schema    string `xorm:"'TABLE_SCHEMA'"`
	Table     string `xorm:"'TABLE_NAME'"`
	Name      string `xorm:"'COLUMN_NAME'"`
	Default   string `xorm:"'COLUMN_DEFAULT'"`
	Nullable  string `xorm:"'IS_NULLABLE'"`
	DataType  string `xorm:"'COLUMN_TYPE'"`
	Key       string `xorm:"'COLUMN_KEY'"`
	CharSet   string `xorm:"'CHARACTER_SET_NAME'"`
	Collation string `xorm:"'COLLATION_NAME'"`
	Comment   string `xorm:"'COLUMN_COMMENT'"`
}

func (Column) TableName() string {
	return "COLUMNS"
}

func (c Column) getColumns(repo *Repo) (items []Column, err error) {
	items=make([]Column,0)
	if err = repo.engine.Where("TABLE_SCHEMA=? and TABLE_NAME=?",c.Schema,c.Table).Find(&items); err != nil {
		return nil, err
	}
	return items, nil
}